gtk/eventscrollerscroll: Handle smooth events in discrete controllers
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 11 Dec 2020 23:37:12 +0000 (00:37 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 12 Dec 2020 00:42:42 +0000 (01:42 +0100)
We let smooth scroll events that don't trigger a ::scroll signal through.
This is unintended, these are handled, even if just accumulated.

This fixes cases like GtkSpinButton inside GtkScrolledWindow, where both
would handle events, until the GtkSpinButton eventually shifts away from
underneath the pointer.

Brought up at https://gitlab.gnome.org/GNOME/gtk/-/issues/593

gtk/gtkeventcontrollerscroll.c

index 261d8bd21e3117b3b2dc0617429fca343f9b3120..44278b0ebb4179cc8032075a45779c092405fecd 100644 (file)
@@ -325,6 +325,9 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
 
   if (dx != 0 || dy != 0)
     g_signal_emit (controller, signals[SCROLL], 0, dx, dy, &handled);
+  else if (direction == GDK_SCROLL_SMOOTH &&
+           (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_DISCRETE) != 0)
+    handled = scroll->active;
 
   if (direction == GDK_SCROLL_SMOOTH &&
       scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
@@ -334,6 +337,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
     {
       g_signal_emit (controller, signals[SCROLL_END], 0);
       scroll->active = FALSE;
+      handled = FALSE;
 
       if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
         {